import 'package:json_annotation/json_annotation.dart';
import 'user.dart';
part 'visit_model.g.dart';

@JsonSerializable()
class VisitModel {
  @JsonKey(defaultValue: [])
  final List<RecordList> recordList;
  @JsonKey(defaultValue: 0)
  final int lastRecordId;
  @JsonKey(defaultValue: false)
  final bool checkLimit;
  @JsonKey(defaultValue: 0)
  final int infoLimitPercent;
  @JsonKey(defaultValue: 0)
  final int infoNowPercent;

  const VisitModel({
    required this.recordList,
    required this.lastRecordId,
    required this.checkLimit,
    required this.infoLimitPercent,
    required this.infoNowPercent,
  });

  factory VisitModel.fromJson(Map<String, dynamic> json) =>
      _$VisitModelFromJson(json);

  Map<String, dynamic> toJson() => _$VisitModelToJson(this);
}

@JsonSerializable()
class RecordList {
  final User? userInfo;
  @JsonKey(defaultValue: 0)
  final int visitTime;
  @JsonKey(defaultValue: 0)
  final int visitNum;
  @JsonKey(defaultValue: 0)
  final int recordId;

  const RecordList({
    this.userInfo,
    required this.visitTime,
    required this.visitNum,
    required this.recordId,
  });

  factory RecordList.fromJson(Map<String, dynamic> json) =>
      _$RecordListFromJson(json);

  Map<String, dynamic> toJson() => _$RecordListToJson(this);
}